package com.jingtai.platform.controller.admin;

import com.jingtai.common.template.ResultMapInfo;
import com.jingtai.core.entity.BaseEntity;
import com.jingtai.core.entity.admin.PlatformAccount;
import com.jingtai.platform.service.admin.PlatformAccountService;
import com.jingtai.platform.util.ResultUtil;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.jingtai.validate.swagger.CApiParam;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import javax.validation.Validator;

/**
 * 平台账户表
 *
 * @author sunlaiqian
 * @date 2020-12-02 18:31:32
 */
@Validated
@RestController
@RequestMapping("/platform/platformaccount")
@Api(tags = "平台账户表")
public class PlatformAccountController {

    @Autowired
    private PlatformAccountService platformAccountService;


    @ApiOperation("平台账户表列表查询")
    @GetMapping("/list")
    public ResultUtil aopPlatformAccountList(@CApiParam(name = "page", value = "页数", required = true, cNotEmpty = true, cIntMin = 1) @RequestParam("page") Integer page,
                                             @CApiParam(name = "limit", value = "每页个数", required = true, cNotEmpty = true, cIntMin = 1) @RequestParam("limit") Integer limit,
                                             @CApiParam(name = "conditions", value = "查询条件", required = false) @RequestParam("conditions") String conditions) {
        return platformAccountService.PlatformAccountlist(page, limit, conditions);
    }


    @ApiOperation("根据ID查询platformAccount实体")
    @GetMapping("/getPlatformAccountById")
    public ResultUtil GetPlatformAccountById(@CApiParam(name = "id", value = "platformAccount实体ID", required = true, cNotEmpty = true) @RequestParam("id") Long id) {
        return platformAccountService.getPlatformAccountById(id);
    }


    @ApiOperation("新增platformAccount实体")
    @PostMapping("/add")
    @ApiOperationSupport(ignoreParameters = {"platformAccount.id", "platformAccount.createTime", "platformAccount.updateTime", "platformAccount.deleteFlag"})
    public ResultUtil aopAddPlatformAccount(@RequestBody @Validated({BaseEntity.Create.class}) PlatformAccount platformAccount) {
        return platformAccountService.addPlatformAccount(platformAccount);
    }

    @ApiOperation("编辑platformAccount实体")
    @PostMapping("/edit")
    @ApiOperationSupport(ignoreParameters = {"platformAccount.createTime", "platformAccount.updateTime", "platformAccount.deleteFlag"})
    public ResultUtil aopEditPlatformAccount(@RequestBody @Validated({BaseEntity.Update.class}) PlatformAccount platformAccount) {
        return platformAccountService.editPlatformAccount(platformAccount);
    }

    @ApiOperation("根据ID删除platformAccount实体")
    @GetMapping("/delPlatformAccountById")
    public ResultUtil aopDelPlatformAccountById(@CApiParam(name = "id", value = "platformAccount实体ID", required = true, cNotEmpty = true) @RequestParam("id") Long id) {
        return platformAccountService.delPlatformAccountById(id);
    }

    @ApiOperation("平台账户登录")
    @PostMapping("/platformLogin")
    @ApiOperationSupport(ignoreParameters = {"platformAccount.id", "platformAccount.platformHead", "platformAccount.nickName", "platformAccount.platformPhone", "platformAccount.email", "platformAccount.signature", "platformAccount.roleId", "platformAccount.enableState", "platformAccount.createTime", "platformAccount.updateTime", "platformAccount.deleteFlag"})
    public ResultUtil platformLogin(@ModelAttribute @Validated({PlatformAccount.Login.class}) PlatformAccount platformAccount) {
        return platformAccountService.platformLogin(platformAccount);
    }

    @ApiOperation("解锁")
    @GetMapping("/unLock")
    public ResultUtil aopUnLock(@CApiParam(name = "id", value = "platformAccount实体ID", required = true, cNotEmpty = true) @RequestParam("id") Long id,
                                @CApiParam(name = "password", value = "密码", required = true, cNotEmpty = true) @RequestParam("password") String password) {
        return platformAccountService.unLock(id,password);
    }

}






